using System;
using System.Data;
using System.Diagnostics;
using System.Xml;

using OR.Reuse.Persistence;

using DataAccess = OR.MyGoals.DataAccess;
using Derived = OR.MyGoals.Model;

namespace OR.MyGoals.Model.Generated
{
	/// <summary>
	/// Defines which Technology Focuses are is required to satisfy your various goals.
	/// </summary>
   public class GoalRequiredExpertise : ModelElementBase<System.Int32, Derived.MyGoalsDataManager>
    {
    
        #region Private Storage
    
		    private System.DateTime mCreated;
		    private System.DateTime mModified;
	
		    private Derived.Goal mGoal;
		    private Derived.Technology mTechnology;
        #endregion

        public GoalRequiredExpertise(Derived.MyGoalsDataManager manager) : base(manager)
        { }


		    public GoalRequiredExpertise()
		    {
	
			      mGoal = new Derived.Goal(this.DataManager);
			      mTechnology = new Derived.Technology(this.DataManager);
		    }
	
		    /// <summary>
		    /// 
		    /// </summary>
		    public Derived.Goal Goal
		    {
			      get { return ( mGoal ); }
            set { mGoal = value; }
		    }

		    /// <summary>
		    /// 
		    /// </summary>
		    public Derived.Technology Technology
		    {
			      get { return ( mTechnology ); }
            set { mTechnology = value; }
		    }

		    /// <summary>
		    /// 
		    /// </summary>
		    public System.DateTime Created
		    {
			      get { return ( mCreated ); }
            set { mCreated = value; }
		    }

		    /// <summary>
		    /// 
		    /// </summary>
		    public System.DateTime Modified
		    {
			      get { return ( mModified ); }
            set { mModified = value; }
		    }

        public override void Refresh()
        {
        DataAccess.GoalRequiredExpertise accessGoalRequiredExpertise = new DataAccess.GoalRequiredExpertise();
           
                DataRow currentRow = accessGoalRequiredExpertise.GetRow(this.Id);

                this.Load(currentRow);
              
        }

        public override void Load(DataRow sourceRow)
        {
        
            this.Id = DataUtility.GetInt32( sourceRow, "Id", 0 );
            this.Goal.Id = DataUtility.GetInt32( sourceRow, "GoalId", 0 );
            this.Technology.Id = DataUtility.GetInt32( sourceRow, "TechnologyId", 0 );
            this.Created = DataUtility.GetDateTime( sourceRow, "Created", DateTime.Now );
            this.Modified = DataUtility.GetDateTime( sourceRow, "Modified", DateTime.Now );
        }

        protected override void SaveNew()
        {
        DataAccess.GoalRequiredExpertise accessGoalRequiredExpertise = new DataAccess.GoalRequiredExpertise();
           
           System.Int32 newId;
           System.DateTime newCreated;
           accessGoalRequiredExpertise.Create(out newId, this.Goal.Id, this.Technology.Id, out newCreated, this.Modified);
           
          this.Id = newId;
           
          this.Created = newCreated;
           
        }

        protected override void SaveExisting()
        {
        DataAccess.GoalRequiredExpertise accessGoalRequiredExpertise = new DataAccess.GoalRequiredExpertise();
           

                accessGoalRequiredExpertise.Update(this.Id, this.Goal.Id, this.Technology.Id, this.Modified);
           
        }
      
    }
    }
  